import jsonpath2


class JSONUtil:

    def __init__(self, obj):
        self._obj = obj

    def get(self, path: str, default=None):
        path = jsonpath2.Path.parse_str(path)
        out = []
        for m in path.match(self._obj):
            out.append(m.current_value)

        if len(out) == 1:
            return out[0]
        elif len(out) == 0:
            return default
        else:
            return out
